<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WJ Admin 后台登录</title>

    <link rel="shortcut icon" href="/favicon.ico">
    <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="/static/admin/css/animate.css" rel="stylesheet">
    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="/static/admin/js/plugins/layer/skin/layer.css">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>if (window.top !== window.self) {
        window.top.location = window.location;
    }</script>
</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>

            <h1 class="logo-name">WJ</h1>

        </div>
        <h3>欢迎使用 WJ Admin</h3>

        <form class="m-t" role="form">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="用户名" autocomplete="off" required="" name="username">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" placeholder="密码" required="" name="password">
            </div>
            {if condition="$show_verify eq 1"}
            <div class="form-group">
                <input type="text" class="form-control" placeholder="验证码" autocomplete="off" required="" name="code">
            </div>
            <div class="form-group">
                <img src="{:url('Login/verify')}" style="cursor: pointer;padding: 6px 12px;" class="verify pull-left"
                     alt="">
            </div>
            {/if}
            <div class="form-group">
                <button type="button" id="login" style="margin-top: 10px;" class="btn btn-primary block full-width m-b">登 录</button>
            </div>

            <p class="text-muted text-center"><a href="">
                <small>忘记密码了？</small>
            </a>
            </p>

        </form>
    </div>
</div>

<!-- 全局js -->
<script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/admin/js/plugins/layer/layer.min.js"></script>
<script type="text/javascript">
    var show_verify = "{$show_verify}";

    $(function () {
        //点击验证码
        $(".verify").click(function () {
            var src = "/admin/login/verify";
            $(this).attr('src', src + "?" + Math.round(Math.random(), 1000));
        });

        $('#login').click(function () {
            $.ajax({
                url: "{:url('admin/Login/checkLogin')}",
                data: $('form').serialize(),
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    if (res.code === 1) {
                        layer.msg(res.msg, {icon: 1}, function () {
                            location.href = "{:url('admin/index/index')}";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                }
            })
        });
    });
</script>
</body>

</html>
